
package com.hexinfo.dmpro.sparing.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hexinfo.dmpro.common.utils.CommonConstants;
import com.hexinfo.dmpro.sparing.model.UatBlackList;
import com.hexinfo.dmpro.sparing.dao.UatBlackListMapper;
import com.hexinfo.dmpro.sparing.service.UatBlackListService;
import org.springframework.stereotype.Service;

/**
 * UAT黑名单表
 *
 * @author yemw
 * @date 2023-11-29 10:37:27
 */
@Service
public class UatBlackListServiceImpl extends ServiceImpl<UatBlackListMapper, UatBlackList> implements UatBlackListService {

    @Override
    public Page queryList(Page page, UatBlackList uatBlackList) {
        LambdaQueryWrapper<UatBlackList> wrapper = Wrappers.lambdaQuery();
        wrapper.like(StrUtil.isNotBlank(uatBlackList.getTblName()),UatBlackList::getTblName,uatBlackList.getTblName())
                .eq(UatBlackList::getDel,CommonConstants.STATUS_NORMAL).orderByDesc(UatBlackList::getCreateTime);
        Page returnPage = this.baseMapper.selectPage(page, wrapper);
        return returnPage;
    }

    @Override
    public boolean saveXG(UatBlackList uatBlackList) {
//        if(uatBlackList.getTblName().contains("%")){
//            uatBlackList.setTblName(uatBlackList.getTblName().replaceAll("_","\\\\\\\\_"));
//        }
        return this.save(uatBlackList);
    }
}
